<ion-header>
  <ion-nav color="whatsapp" class="messages-page-navbar">
    <ion-buttons>
      <img class="chat-picture" [src]="picture">
    </ion-buttons>

    <ion-title class="chat-title">{{title}}</ion-title>

    <ion-buttons end>
      <button ion-button icon-only class="attach-button"><ion-icon name="attach"></ion-icon></button>
      <button ion-button icon-only class="options-button"><ion-icon name="more"></ion-icon></button>
    </ion-buttons>
  </ion-nav>
</ion-header>

<ion-content padding class="messages-page-content">
  <div scrollY="true" class="messages">
    <div *ngFor="let day of messagesDayGroups | async" class="day-wrapper">
      <div *ngFor="let message of day.messages" class="message-wrapper">
        <div [class]="'message message-' + message.ownership">
          <div *ngIf="message.type == 'text'" class="message-content message-content-text">{{message.content}}</div>
          <span class="message-timestamp">{{ message.createdAt }}</span>
        </div>
      </div>

      <div *ngIf="!day.today" class="day-timestamp">{{day.timestamp}}</div>
    </div>
  </div>
</ion-content>

<ion-footer>
  <ion-toolbar color="whatsapp" class="messages-page-footer" position="bottom">
    <ion-input [(ngModel)]="message" (keypress)="onInputKeypress($event)" class="message-editor" placeholder="Type a message"></ion-input>

    <ion-buttons end>
      <button ion-button icon-only *ngIf="message" class="message-editor-button" (click)="sendTextMessage()">
        <ion-icon name="send"></ion-icon>
      </button>

      <button ion-button icon-only *ngIf="!message" class="message-editor-button">
        <ion-icon name="mic"></ion-icon>
      </button>
    </ion-buttons>
  </ion-toolbar>
</ion-footer>